const state = {
  userInfo:null,
  checkTaskIds:[],
  checkTasks:[],
  CADpartPath:[],
  CADLayoutPath:[],
  clearFilterCode:null,
  partRefreshList:null,
  processType:1
}

const mutations = {
  SET_APP_USERINFO: (state, user) => {
    //用户等于数据
    state.userInfo=user;
  },
  SET_CHECK_TASK_IDS: (state, ids) => {
    //作业数据 多选id结果集合
    state.checkTaskIds=Array.isArray(ids)?ids:[]; 
  },
  SET_CHECK_TASKS:(state, tasks)=>{
    //作业数据 多选结果集合
    state.checkTasks=Array.isArray(tasks)?tasks:[];
  },
  SET_CAD_PART_PATH:(state, urls)=>{
    // 零件数据CAD 已处理结果保存
    state.CADpartPath=Array.isArray(urls)?urls:[];
  },
  CLEAR_TABLE_HEADER_FILTER:(state, code)=>{
    //充值所有table 头部checkbox与排序
    state.clearFilterCode=new Date().getTime();
  },
  SET_CAD_LAYOUT:(state, urls)=>{
    // 排样数据CAD 已处理结果保存
    state.CADLayoutPath=Array.isArray(urls)?urls:[];
  },
  SET_PART_REFRESH_LIST:(state, urls)=>{
    // 刷新零件列表
    state.partRefreshList=new Date().getTime();
  },
  SET_PROCESS_TYPE:(state, type)=>{
    // 板材型材切换
    state.processType=type;
  },
}

const actions = {
  setAppUserInfo({ commit }, user) {
    commit('SET_APP_USERINFO', user)
  },
  setCheckTaskIds({ commit }, ids) {
    commit('SET_CHECK_TASK_IDS', ids)
  },
  setCheckTasks({ commit }, tasks) {
    commit('SET_CHECK_TASKS', tasks)
  },
  setCADpartPath({ commit }, urls) {
    commit('SET_CAD_PART_PATH', urls)
  },
  clearTableHeaderFilter({ commit }) {
    commit('CLEAR_TABLE_HEADER_FILTER')
  },
  setCADLayout({ commit }, urls) {
    commit('SET_CAD_LAYOUT', urls)
  },
  setPartRefreshList({ commit }) {
    commit('SET_PART_REFRESH_LIST')
  },
  setProcessType({ commit },type) {
    commit('SET_PROCESS_TYPE',type)
  },
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
